$(document).ready(function(){
    if (/MicroMessenger/.test(window.navigator.userAgent)) { //从微信进入支付
        $("#alipay").hide();
    }
    var wx5 = /x5app/.test(navigator.userAgent) && !window.MSStream;
    if(wx5){
        // $("#weixin").hide();
    }else{
        $(".my").css("margin-top","0");
    }
});
$("input[type='radio']").click(function(){
    var val_r = $(this).val();
    $(".box_c_a").addClass("box_c_not");
    $(".box_c_a").removeClass("box_c_a");
    $(this).siblings().addClass("box_c_a");
    $(this).siblings().removeClass("box_c_not");
});
$(".box_d_1").click(function (){
    var channelId = $("input[type='radio']:checked").val();//取到的value
    if (channelId == "0") {
        channelId = "ALIPAY_WAP";
    }else if (channelId == "1") {
        if (/MicroMessenger/.test(window.navigator.userAgent)) { //从微信进入支付
            channelId = "WX_JSAPI";
            $("")
        } else {
            channelId = "WX_MWEB";
        }
    }else{
        var  remainPart=$("input[type='radio']:checked").attr('remainPart');//账户余额
        var  currency=$("input[type='radio']:checked").attr('currency');
        var  echoAmount=$("input[type='radio']:checked").attr('echoAmount'); //订单总额
        if( parseFloat(remainPart - echoAmount) <0){
            simpleHints(currency+"余额不足,请选择其他支付方式");
            return ;
        }
    }
    var referLink = document.createElement('a');
    referLink.href = "/createPayInfo?r="+Math.random()+ "&channelId=" + channelId;//"ALIPAY_WAP";
    document.body.appendChild(referLink);
    referLink.click();
});
$(".close").click(function (){
    $(".box_e").hide();
    $(".box_e_5,#one,#two,#three,#four,#five,#sex").val("");
});
(function(){
    var container = document.getElementById("inputBoxContainer");
    boxInput = {
        maxLength:"",
        realInput:"",
        bogusInput:"",
        bogusInputArr:"",
        callback:"",
        init:function(fun){
            var that = this;
            this.callback = fun;
            that.realInput = container.children[0];
            that.bogusInput = container.children[1];
            that.bogusInputArr = that.bogusInput.children;
            that.maxLength = that.bogusInputArr[0].getAttribute("maxlength");
            that.realInput.oninput = function(){
                that.setValue();
            }
            that.realInput.onpropertychange = function(){
                that.setValue();
            }
        },
        setValue:function(){
            this.realInput.value = this.realInput.value.replace(/\D/g,"");
            var real_str = this.realInput.value;
            for(var i = 0 ; i < this.maxLength ; i++){
                this.bogusInputArr[i].value = real_str[i]?real_str[i]:"";
            }
            if(real_str.length == this.maxLength){
                this.realInput.value = real_str.substring(0,6);
                this.callback();
            }
        }, getBoxInputValue:function(){
            var realValue = "";
            console.log(this.bogusInputArr);
            for(var i in this.bogusInputArr){
                if(!this.bogusInputArr[i].value){
                    break;
                }
                if(parseInt(0)<= i &&  i <= parseInt(6)){
                    realValue += this.bogusInputArr[i].value;
                }
            }
            return realValue;
        }
    }
})();
function simpleHints(obj) {
    $("body").append($("<div id='prompt'></div>"));
    document.getElementById("prompt").innerHTML = obj;
    document.getElementById("prompt").style.display = "block";
    setTimeout('document.getElementById("prompt").style.display= "none";', 1500)
}